home *** CD-ROM | disk | FTP | other *** search
/ PC go! 2013 December / PCGO_13-12_CD.iso / nw.pak / Unnamed File 000853.txt < prev    next >
Encoding:
Text File  |  2012-12-14  |  2.2 KB  |  76 lines

  1. // Copyright (c) 2012 Intel Corp
  2. // Copyright (c) 2012 The Chromium Authors
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. //  in the Software without restriction, including without limitation the rights
  7. //  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co
  8. // pies of the Software, and to permit persons to whom the Software is furnished
  9. //  to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in al
  12. // l copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM
  15. // PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES
  16. // S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  17. //  OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH
  18. // ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. //  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20.  
  21. var argv, fullArgv;
  22.  
  23. function App() {
  24. }
  25. require('util').inherits(App, exports.Base);
  26.  
  27. App.filteredArgv = [
  28.   /--no-toolbar/,
  29.   /--url=.*/,
  30.   /--remote-debugging-port=.*/,
  31. ];
  32.  
  33. App.prototype.quit = function() {
  34.   nw.callStaticMethod('App', 'Quit', [ ]);
  35. }
  36.  
  37. App.prototype.closeAllWindows = function() {
  38.   nw.callStaticMethod('App', 'CloseAllWindows', [ ]);
  39. }
  40.  
  41. App.prototype.__defineGetter__('argv', function() {
  42.   if (!argv) {
  43.     var fullArgv = this.fullArgv;
  44.     argv = [];
  45.     for (var i = 0; i < fullArgv.length; ++i) {
  46.       var matched = false;
  47.       for (var j = 0; j < App.filteredArgv.length; ++j) {
  48.         if (App.filteredArgv[j].test(fullArgv[i])) {
  49.           matched = true;
  50.           break;;
  51.         }
  52.       }
  53.       if (matched)
  54.         continue;
  55.  
  56.       argv.push(fullArgv[i]);
  57.     }
  58.   }
  59.  
  60.   return argv;
  61. });
  62.  
  63. App.prototype.__defineGetter__('fullArgv', function() {
  64.   if (!fullArgv)
  65.     fullArgv = nw.callStaticMethodSync('App', 'GetArgv', [ ]);
  66.  
  67.   return fullArgv;
  68. });
  69.  
  70. // Store App object in node's context.
  71. if (process['_nw_app']) {
  72.   exports.App = process['_nw_app'];
  73. } else {
  74.   exports.App = process['_nw_app'] = new App();
  75. }
  76.